﻿using Translator.GoogleTranslateApi;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;
using System.Xml.Linq;

namespace TestSkypeComponents
{


	/// <summary>
	///This is a test class for GoogleTranslateApiTest and is intended
	///to contain all GoogleTranslateApiTest Unit Tests
	///</summary>
	[TestClass()]
	public class GoogleTranslateApiTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		// 
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion


		/// <summary>
		///A test for Translate
		///</summary>
		[TestMethod()]
		public void TranslateGoogleTest()
		{
			GoogleTranslateApiImplementation target = new GoogleTranslateApiImplementation();
			string textToTranslate = "Hello world";
			string expected = "Привет мир";
			string actual;
			target.SetSourceLanguage("en");
			target.SetTranslateLanguage("ru");

			actual = target.Translate(textToTranslate);
			Assert.AreEqual(expected, actual);
			Assert.Inconclusive("Verify the correctness of this test method.");
		}

		/// <summary>
		///A test for TranslateGoogle
		///</summary>
		[TestMethod()]
		public void TranslateGoogleTest1()
		{
			GoogleTranslateApiImplementation target = new GoogleTranslateApiImplementation();
			string text = "Hello world";
			string fromCulture = "en";
			string toCulture = "ru";
			string expected = "Привет мир";
			string actual;
			target.SetTranslateLanguage(toCulture);
			target.SetSourceLanguage(fromCulture);
			actual = target.TranslateGoogle(text);
			Assert.AreEqual(expected, actual);
		}

		[TestMethod()]
		public void TranslateGoogleObjectTest()
		{
			GoogleTranslateApiImplementation target = new GoogleTranslateApiImplementation();
			string text = "Hello world. this is my firs test. You should keep silence";
			string fromCulture = "en";
			string toCulture = "ru";
			dynamic actual;
			target.SetTranslateLanguage(toCulture);
			target.SetSourceLanguage(fromCulture);
			actual = target.TranslateGoogleObject(text);
			Assert.AreEqual(((GoogleTranslateApiImplementation.GoogleTranslateResponse)actual).sentences.Count, 3);
		}
	}
}
